package com.itany.corejava.code08_常用类.练习3;

/**
 * @author MissChen
 * @version 1.0
 * @date 2023 年11月16日 14:31
 */

/**
 * 定义一个Pet泛型类，里面有一个未知的类型
 *  属性:
 *      name
 *      age
 *      detail(但是deatail是啥类型，目前未知)
 *
 *
 *
 * 定义一个AA类
 *      AA类
 *          有一个属性：爱好
 *          构造方法
 *          getset方法
*       BB类继承AA类
 *          有一个属性：地址
 *          构造方法
 *  *          getset方法
 *      CC类继承BB类
 *          有一个属性:主人名字
 *          构造方法
 *  *       getset方法
 *
 *
 *   定义一个测试类
 *   测试类中定义两个静态方法
 *     第一个静态方法:返回的是Pet<? extends AA>
 *         静态方法中实现的功能是:(无参)
 *              将要返回的Pet实例中的detail设置为指定实例BB(该指定实例中需要填入参数)
*
 *     第二个静态方法:返回的是Pet<? super CC>
 *          静态方法中实现的功能是:
 *                将要返回的Pet实例中的detail设置为指定实例AA(该指定实例中需要填入参数)
 */
public class Pet<T>{
    private String name;
    private int age;
    private T deatil;

    public Pet() {
    }

    public Pet(String name, int age, T deatil) {
        this.name = name;
        this.age = age;
        this.deatil = deatil;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public T getDeatil() {
        return deatil;
    }

    public void setDeatil(T deatil) {
        this.deatil = deatil;
    }

    @Override
    public String toString() {
        return "Pet{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", deatil=" + deatil +
                '}';
    }
}

class AA{
    private String hobby;

    public AA(String hobby) {
        this.hobby = hobby;
    }

    public String getHobby() {
        return hobby;
    }

    public void setHobby(String hobby) {
        this.hobby = hobby;
    }

    @Override
    public String toString() {
        return "AA{" +
                "hobby='" + hobby + '\'' +
                '}';
    }
}
class BB extends  AA{
    private String address;

    public BB(String hobby, String address) {
        super(hobby);
        this.address = address;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    @Override
    public String toString() {
        return "BB{" +
                "address='" + address + '\'' +
                '}';
    }
}
class CC extends  BB{
    private String owner;

    public CC(String hobby, String address, String owner) {
        super(hobby, address);
        this.owner = owner;
    }

    public String getOwner() {
        return owner;
    }

    public void setOwner(String owner) {
        this.owner = owner;
    }

    @Override
    public String toString() {
        return "CC{" +
                "owner='" + owner + '\'' +
                '}';
    }
}